﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceModel;
using System.ServiceProcess;
using System.Text;

namespace StockProxyService
{
    public partial class StockProxy : ServiceBase
    {
        public ServiceHost serviceHost = null;

        public StockProxy()
        {
            InitializeComponent();
        }

        protected override void OnStart(string[] args)
        {
            try
            {
                if (serviceHost == null)
                {
                    serviceHost = new ServiceHost(typeof(WcfSP));
                    serviceHost.Open();
                    Log.Write("服务成功启动.");
                }
            }
            catch (Exception exp)
            {
                Log.Write(exp.Message);
            }
        }

        protected override void OnStop()
        {

            if (serviceHost != null)
            {
                serviceHost.Close();
                serviceHost = null;
            }
            Log.Write("服务已经关闭.");
        }
    }
}
